<template>
	<view class="tab-bar">
		<view :class="['item', {'active':selected === index}]" v-for="(item, index) in list" :key="index"
			@click="switchTab(item.pagePath)">
			<image class="img" :src="selected === index ? item.selectedIconPath : item.iconPath"></image>
			<view class="text"> {{item.text}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			selected: {
				type: Number,
				require: true,
			}
		},
		data() {
			return {
				color: "#dededede",
				backgroundColor: "#fff",
				selectedColor: "#F27121",
				borderStyle: "white",
				list: [{
						pagePath: "/pages/user/index",
						text: "مېنىڭ",
						iconPath: "/static/images/Minig-2.svg",
						selectedIconPath: "/static/images/Minig.svg"
					},
					{
						pagePath: "/pages/kisimlik/index",
						text: "قىسىملىق",
						iconPath: "/static/images/Qisimliq-2.svg",
						selectedIconPath: "/static/images/Qisimliq.svg"
					},
					{
						pagePath: "/pages/sannat/index",
						text: "سەنئەت",
						iconPath: "/static/images/Senet-2.svg",
						selectedIconPath: "/static/images/Senet.svg"
					},
					{
						pagePath: "/pages/kino/index",
						text: "كىنولار",
						iconPath: "/static/images/kino-2.svg",
						selectedIconPath: "/static/images/kino.svg"
					},
					{
						pagePath: "/pages/index/index",
						text: "باش بەت",
						iconPath: "/static/images/Bashbet-2.svg",
						selectedIconPath: "/static/images/Bashbet.svg"
					}
				],
			}
		},
		methods: {
			switchTab(pagePath) {
				uni.redirectTo({
					url: pagePath
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.tab-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 68px;
		box-shadow: 1px 10px 20px #000;
		background: #fff;
		padding-bottom: constant(safe-area-inset-bottom);
		display: flex;
		align-items: center;

		.item {
			width: 25%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			&.active {
				.text {
					color: #08C1FF;
				}
			}

			.img {
				display: block;
				width: 25px;
				height: 25px;
			}

			.text {
				color: #888888;
				font-size: 24rpx;
				margin-top: 10rpx;
			}
		}
	}
</style>